package com.myres.promotionitem.db;
import com.myres.db.ConnectionPool;
import com.myres.model.Category;

import java.util.List;
import java.util.ArrayList;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import com.myres.model.Product;
public class PromotionItemService {
     public List<Product> getRecommendItems(){
    	 Connection con=null;
    	 PreparedStatement pstmt=null;
    	 ResultSet rs=null;
    	 try{
    		 con=ConnectionPool.getPool().getConnection();
    		 pstmt=con.prepareStatement("select * from res_products where _on_promotion=1");
    		 rs=pstmt.executeQuery();
    		 return Product.populate(rs);
    	 }catch(Exception e){
    		 e.printStackTrace();
    		 return null;
    	 }finally{
    		 try{
    		     rs.close();
    		     pstmt.close();
    		     con.close();
    		 }catch(Exception e){
    		 }
    		 
    	 }
     }
}